<%@page import="funda.appius.arquitectura.StringEncrypter"%>
<%@page import="java.util.Random"%>
<%@page import="java.security.SecureRandom"%>
<%@page import="java.math.BigInteger"%>
<%@page import="funda.appius.arquitectura.Email"%>
<%@page import="funda.appius.arquitectura.Mensaje"%>
<%@page import="org.joda.time.DateTime"%>
<%@page import="funda.appius.Constructora.Usuario"%>
<%@page import="java.util.ArrayList"%>
<%@page import="funda.appius.Constructora.Constructora"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();
    String fecha = dateFormat.format(date);
%>

<%
    if(request.getParameter("submit")!=null)
    {
        String nombre = request.getParameter("nombre");
        String direccion = request.getParameter("direccion");
        String rfc = request.getParameter("rfc");
        int telefono = Integer.parseInt(request.getParameter("telefono"));
        String email = request.getParameter("email");
        
        String jnombre = request.getParameter("jnombre");
        String jusuario = request.getParameter("jusuario");
        String jpassword = request.getParameter("jpassword");
        String jemail = request.getParameter("jemail");
        
        
        Email mail = new Email();
         Boolean envio = mail.sendEmail("fundaappius@gmail.com", "funda.org",jemail, "Bienvenido a Funda Appius!", "Bienvenido a Funda Appius");
        if(envio){
            String descripcion = request.getParameter("descripcion");
            java.sql.Date d = new java.sql.Date(java.sql.Date.parse(fecha));
            Constructora constructora = new Constructora(nombre,direccion,rfc,telefono,email,descripcion,d,new ArrayList<Usuario>());
            Usuario u = new Usuario(1,jnombre,jusuario,jpassword,jemail,constructora.getIdConstructora());
            String cUsuario = StringEncrypter.getString(u.getIdUsuario()+"");
            Mensaje.Mostrar(response, u.getIdUsuario()+"");
            String vinculo = "http://appius.funda.org:8080/FundaAppius/ActivarCuenta.jsp?gzj5="+cUsuario;
            mail.sendEmail("fundaappius@gmail.com", "funda.org",jemail, "Bienvenido a Funda Appius!", "Bienvenido a Funda Appius, Para Activar tu Cuenta has Click en: " + vinculo);
             Mensaje.Mostrar(response, "Se Ha Dado de Alta Y Mandado Correo para Activar la Cuenta");
            
        }
        else
        {
            Mensaje.Mostrar(response, "Error: Correo No Existe");
        }
    }
    
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registro</title>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<link href="fonts/stylesheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#search').focus(function() {
  $('#subm').addClass('active');
});
$('#search').blur(function() {
  $('#subm').removeClass('active');
});
})
</script>
<!--SCRIPT FOR MENU-->
<script type="text/javascript">
<!--
$(document).ready(function () {	
	
	$('#navbar li').hover(
		function () {
			//show its submenu
			$('ul', this).slideDown();
			$('ul li ul', this).slideUp(0);

		}, 
		function () {
			//hide its submenu
			$('ul', this).slideUp();
		}
	);

});
-->
</script>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
<!-- End of Js file for form validation popups -->
<!--***************************************************************-->
<script type="text/javascript">
<!--
$(document).ready(function () {	
	
	// For form validation
	$("#formID").validationEngine({
		
	})
	// End of form Validation

});
-->
</script>
<script type="text/javascript" src="js/contactable/jquery.validate.pack.js"></script>
<script type="text/javascript" src="js/contactable/jquery.contactable.js"></script>
<link rel="stylesheet" href="js/contactable/contactable.css" type="text/css" />
<script type="text/javascript">
	$(function(){
		$('#contact').contactable({
	 		subject: 'A Feeback Message'
	 	});
	});
</script>
 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 <script type="text/javascript" src="fancybox/jquery.fancybox.js?v=2.0.6"></script>
</head>
<body>

    <div id="wraper">
 <div id="head">
  <div class="centerAlign"> <a href="index.html" class="logo"><img src="images/logo.png" alt="" /></a> <img src="images/topGfx.png" alt="" class="topGfx" />
   <div id="navbar">
    <ul>
     <li class=""><a href="index.jsp">Home</a></li>
     <li class="">&nbsp;</li>
     <li><a href="#">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
     </li>
     <li class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
     <li><a href="#">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
     </li>
     <li class="">&nbsp;</li>
     <li><a href="">&nbsp;</a>
     </li>
     <li class="sep"></li>
     <li ><a href="iniciarsesion.jsp">Iniciar Sesion</a> 
     </li>
     <li class="sep">&nbsp;</li>
     <li><a href="#">&nbsp;</a></li>
     <li class="">&nbsp;</li>
     <li class="active"><a href="registro.jsp">Registro</a></li>
    </ul>
   </div>
  </div>
    
    
 <div id="content">
  <div class="centerAlign">
   <div class="wrap1">
    <div class="wrap2">
     <div class="main_wrap">
      <!--Content Start-->
      <div class="full_width">
    </div>
    <div class="left_pannel">
     <h3>Datos Constructora</h3>
     <form action="registro.jsp" method="POST" class="mail" id="formID">

     <input name="nombre" type="text" value="Nombre Constructora" id="nombre" class="validate[required,exemptString[Nombre Constructora]]"  onfocus="if(this.value=='Nombre Constructora')this.value='';"  onblur="if(this.value=='')this.value='Nombre Constructora';" />
     <input name="direccion" type="text" value="Direccion Constructora" id="direccion" class="validate[required,exemptString[Direccion Constructora]]" onfocus="if(this.value=='Direccion Constructora')this.value='';"  onblur="if(this.value=='')this.value='Direccion Constructora';"  />
     <input name="rfc" type="text" value="RFC" id="rfc" class="validate[required,exemptString[RFC]]" onfocus="if(this.value=='RFC')this.value='';"  onblur="if(this.value=='')this.value='RFC';"  />
     <input name="telefono" type="text" value="Telefono" id="telefono" class="validate[required,exemptString[Telefono]]" onfocus="if(this.value=='Telefono')this.value='';"  onblur="if(this.value=='')this.value='Telefono';"  />
     <input name="email" type="text" value="E-mail" id="email" class="validate[required,exemptString[E-mail]]" onfocus="if(this.value=='E-mail')this.value='';"  onblur="if(this.value=='')this.value='E-mail';"  />
     <input name="descripcion" type="text" value="Descripcion" id="descripcion" />
   
    
   
    <div class="three_equals">
     <h3>Datos Administrador / Gerente</h3>
   
     <input name="jnombre" type="text" value="Nombre Completo" id="jnombre" class="validate[required,exemptString[Nombre Completo]]"  onfocus="if(this.value=='Nombre Completo')this.value='';"  onblur="if(this.value=='')this.value='Nombre Completo';" />
     <input name="jusuario" type="text" value="Nombre Usuario" id="jdireccion" class="validate[required,exemptString[Nombre Usuario]]" onfocus="if(this.value=='Nombre Usuario')this.value='';"  onblur="if(this.value=='')this.value='Nombre Usuario';"  />
     <input name="jpassword" type="text" value="Password" id="jrfc" class="validate[required,exemptString[Password]]" onfocus="if(this.value=='Password')this.value='';"  onblur="if(this.value=='')this.value='Password';"  />
     <input name="jemail" type="text" value="E-mail" id="jtelefono" class="validate[required,exemptString[E-mail]]" onfocus="if(this.value=='E-mail')this.value='';"  onblur="if(this.value=='')this.value='E-mail';"  />
     <input type="submit" onclick="return confirm('Estan Correctos los Datos?');" name="submit" value="Submit" />
    
     </p>
      </form>
    </div>
     <h3>Map</h3>
     <iframe class="map" width="300" height="190" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=1090+25th+Place,+Bradenton,+FL+34203,+United+States&amp;ie=UTF8&amp;hq=&amp;hnear=1090+25th+St+W,+Bradenton,+Manatee,+Florida+34205&amp;ll=27.490152,-82.585945&amp;spn=0.015989,0.025663&amp;z=14&amp;iwloc=A&amp;output=embed"></iframe>
     <br />
     <small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=1090+25th+Place,+Bradenton,+FL+34203,+United+States&amp;ie=UTF8&amp;hq=&amp;hnear=1090+25th+St+W,+Bradenton,+Manatee,+Florida+34205&amp;ll=27.490152,-82.585945&amp;spn=0.015989,0.025663&amp;z=14&amp;iwloc=A" class="more">Full View</a></small> </div>
      <!--Content End-->
     </div>
    </div>
   </div>
  </div>
 </div>
     </div>
 <div id="footer">

  <div class="fwrap">
   <div class="centerAlign">
    <ul class="footNav">
     <li><a href="#">Home</a></li>
     <li class="sep">|</li>
     <li><a href="#">About</a></li>
     <li class="sep">|</li>
     <li><a href="#">Services</a></li>
     <li class="sep">|</li>
     <li><a href="#">Blog</a></li>
     <li class="sep">|</li>
     <li><a href="contact.html">Contact</a></li>
    </ul>
    <p class="credit">© All Rights Reserved.<br />
     Designed By: <a href="http://www.fundateam.org/" target="_blank">Funda ORG</a></p>
   </div>
  </div>
 </div>

</body>
</html>
